﻿@inherits AntDomComponentBase

<Dropdown Style="display: inherit; width: inherit;"
          OverlayClassName="container">
    <Overlay>
        <Menu Class="menu" OnMenuItemClicked="OnItemSelected">
            @foreach (var avatarItem in MenuItems)
            {
                if (avatarItem.IsDivider)
                {
                    <MenuDivider />
                }
                else
                {
                    <MenuItem Key="@avatarItem.Key">
                        <Icon Type="@avatarItem.IconType" Theme="@avatarItem.IconTheme" />
                        @avatarItem.Option
                    </MenuItem>
                }
            }
        </Menu>
    </Overlay>
    <Unbound>
        <span @ref="@context.Current" class="action account">
            <Avatar Size="@Size" Class="avatar" Src="@Avatar" Alt="avatar" />
            <span class="name anticon">@Name</span>
        </span>
    </Unbound>
</Dropdown>

@code {
    [Parameter] public string Avatar { get; set; }
    [Parameter] public string Size { get; set; } = "small";
    [Parameter] public string Name { get; set; }
    [Parameter] public EventCallback<MenuItem> OnItemSelected { get; set; }

    [Parameter]
    public IEnumerable<AvatarMenuItem> MenuItems { get; set; } =
    new AvatarMenuItem[]
    {
            new AvatarMenuItem { Key = "center", IconType = "user", Option = "个人中心"},
            new AvatarMenuItem { Key = "setting", IconType = "setting", Option = "个人中心"},
            new AvatarMenuItem { IsDivider = true },
            new AvatarMenuItem { Key = "logout", IconType = "logout", Option = "个人中心"}
    };
}